var SVGInputMethod = InputMethod.extend({
	button_new: null,
	constructor: function()
	{
	},
	IMName: function()
	{
		return 'SVG';
	},
	GetLanguage: function()
	{
		return 'util';
	},
	onActive: function()
	{
		var factory;
		var x = this;

		factory = this.ime.mainwin.GetExtensionFactory();
		this.button_new = factory.CreateText();
		this.button_new.SetText('New');
		this.button_new.SetClickHandler(function() { x.NewSVG(); });
	},
	onDeactive: function()
	{
		this.button_new.Destroy();
		this.button_new = null;
	},
	onModify: function(obj)
	{
		alert(obj);
	},
	NewSVG: function()
	{
		var ns;
		var obj,svg,o,d;
		var adapter,html;

		obj = this.ime.last_focus_obj;
		if(!obj) return false;

		ns = 'http://www.w3.org/2000/svg';
		adapter = GownFullObjectAdapter.GetAdapter(obj);
		if(adapter && adapter.isHTML()) {
/*			svg = document.createElementNS(ns,'svg');
			o = document.createElementNS(ns,'rect');
			o.setAttributeNS(null,'x','1px');
			o.setAttributeNS(null,'y','1px');
			o.setAttributeNS(null,'width','10px');
			o.setAttributeNS(null,'height','10px');
			svg.appendChild(o);
			adapter.MozillaInsertNodeAtSelection(adapter.obj.contentWindow,d);*/
			html = '<object id="svg" data="blank.svg" width="300" height="100" type="image/svg+xml" codebase="http://www.adobe.com/svg/viewer/install/" onclick="alert(1)" />';
			adapter.SendHTML(obj,html);
			adapter.SetHTMLElementEventById('svg',"click",function(e) { alert('hello'); return false; });

		}
		else {
			alert("Must be RichEdit");
		}
	}
});


